package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.declare.cebInvt.request.CebInvtQueryRequest;
import com.dwms.entity.declare.cebInvt.request.CebInvtRequest;
import com.dwms.entity.declare.cebInvt.response.CebInvtResponse;
import com.dwms.entity.declare.cebInvtReceipt.response.CebInvtReceiptResponse;
import com.dwms.entity.declare.cebOrderReceipt.response.CebOrderReceiptResponse;
import com.dwms.feign.declare.CebInvtFeignClient;
import com.dwms.feign.declare.CebInvtReceiptFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: CebInvtController
 * @Description: CebInvt
 * @Create 2025-09-15 23:08:20
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "清单备案信息")
@RestController
@RequestMapping(value = "/declare/cebInvt")
@RequiredArgsConstructor
public class CebInvtController {

    private final HttpServletRequest request;
    private final CebInvtFeignClient cebInvtFeignClient;
    private final CebInvtReceiptFeignClient cebInvtReceiptFeignClient;

    /**
     * 修改
     *
     * @param cebInvtRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result update(@RequestBody CebInvtRequest cebInvtRequest) {
        WebUtil.getAdminRequest(request,cebInvtRequest);
        return cebInvtFeignClient.update(cebInvtRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebInvtResponse>> findPage(@RequestBody CebInvtQueryRequest query) {
        WebUtil.getAdminRequest(request,query);
        return cebInvtFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebInvtFeignClient.findById(query);
    }


    /**
     * 回执查询
     * @param query
     * @return
     */
    @Operation(summary = "回执查询")
    @PostMapping("/findByOrderId")
    public Result<List<CebInvtReceiptResponse>> findByOrderId(@RequestBody QueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return this.cebInvtReceiptFeignClient.findByOrderId(query);
    }

    /**
     * 申报
     *
     * @param query
     * @return
     */
    @Operation(summary = "申报")
    @PostMapping("/declare")
    public Result declare(@RequestBody QueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return this.cebInvtFeignClient.declare(query);
    }

}
